﻿using System;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PicSolve;

namespace PicTests
{
    [TestClass]
    public class PicSolverTest
    {
        [TestMethod]
        public void GetSimpleCoverPossTest()
        {
            var pli = new PLineInd(10, new int[1] { 6 });
            var list = pli.GetSimpleCoverPoss().Select(l => l.ToString());
            Assert.IsTrue(
                            list.Count() == 2 &&
                            //list.Count() == 5 &&
                            list.Contains("111111----") &&
                            //list.Contains("-111111---") &&
                            //list.Contains("--111111--") &&
                            //list.Contains("---111111-") &&
                            list.Contains("----111111")
                            );


            pli = new PLineInd(10, new int[2] { 6, 3 });
            list = pli.GetSimpleCoverPoss().Select(l => l.ToString());
            Assert.IsTrue(list.Count() == 1 && list.Contains("1111110111"));
        }

        [TestMethod]
        public void TrySolveTest()
        {
            var pli = new PLineInd(10, new int[1] { 8 });
            Assert.IsTrue(pli.TrySolve().Line.ToString().Equals("--111111--"));

            pli = new PLineInd(10, new int[1] { 10 });
            Assert.IsTrue(pli.TrySolve().Line.ToString().Equals("1111111111"));

            pli = new PLineInd(10, new int[2] { 6, 3 });
            Assert.IsTrue(pli.TrySolve().Line.ToString().Equals("1111110111"));
        }
    }
}
